转载 : Solution of java.lang.IllegalArgumentException: View not attached to window manager
如果某个活动已经被销毁,还在该活动的上下文里弹出或者关闭对话框的话,会导致“java.lang.IllegalArgumentException: View not attached to window manager”异常。解决办法就是,在弹出或关闭对话框之前,使用isFinishing()检查一下该活动是否还存活着。
亮点:
@Override
public void dismiss()
{
if (mParentActivity != null && !mParentActivity.isFinishing())
{
super .dismiss(); // 调用超类对应方法
}
}
Your opinionsHxLauncher: Launch Android applications by voice commands